package custom;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.qianfeng.lingshijia.DetailsActivity;
import com.qianfeng.lingshijia.MainActivity;
import com.qianfeng.lingshijia.R;
import com.qianfeng.lingshijia.TotalListActivity;
import com.qianfeng.lingshijia.TotalListActivity_Import;
import com.qianfeng.lingshijia.TotalListActivity_Report;

/**
 * Created by yerj on 2016/1/11.
 */
public class NavTypeView extends LinearLayout{

    TextView navtv,alltv;
    String allUrl = null;

    public void setAllUrl(String allUrl){
        this.allUrl = allUrl;
    }

    public NavTypeView(Context context) {
        super(context);
        init();
    }

    public NavTypeView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        LayoutInflater.from(getContext()).inflate(R.layout.nav_type_layout, this);
        navtv = (TextView) findViewById(R.id.id_nav_title);
        alltv = (TextView) findViewById(R.id.id_title_all);

        alltv.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent;
                if ("http://cmsproxy.haolingzui.com/importBulkProducts.do".equals(allUrl))
                {
                    intent = new Intent(getContext(), TotalListActivity_Import.class);

                }else if("http://cmsproxy.haolingzui.com/reportList.do".equals(allUrl))
                {
                    intent = new Intent(getContext(), TotalListActivity_Report.class);
                }
                else {
                    intent = new Intent(getContext(), TotalListActivity.class);
                }

                intent.putExtra("url",allUrl);

                getContext().startActivity(intent);
                Toast.makeText(getContext(),allUrl,Toast.LENGTH_SHORT).show();

            }
        });

    }

    public void setData(final String title){
        this.navtv.setText(title);
    }

}
